cmake_minimum_required(VERSION 3.16)
project(NekoPa VERSION 1.1.1)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Enable static runtime on Windows to avoid DLL dependencies
if(WIN32)
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

# Define resource files
set(RESOURCE_FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/resource.rc
)

# Define source files
set(SOURCE_FILES
    src/main.cpp
    src/WindowManager.cpp
    src/KeyboardHook.cpp
    src/DataManager.cpp
)

# Define header files
set(HEADER_FILES
    src/WindowManager.h
    src/KeyboardHook.h
    src/DataManager.h
    resource.h
)

# Create executable (WIN32 app)
add_executable(${PROJECT_NAME} WIN32
    ${SOURCE_FILES}
    ${HEADER_FILES}
    ${RESOURCE_FILES}
)

# Set output file name with version
set_target_properties(${PROJECT_NAME} PROPERTIES
    OUTPUT_NAME "NekoPa-V${PROJECT_VERSION}"
)

# Link Windows libraries for DirectComposition
target_link_libraries(${PROJECT_NAME}
    user32
    gdi32
    kernel32
    shell32
    comctl32
    d2d1         # Direct2D for hardware-accelerated 2D graphics
    d3d11        # Direct3D 11 for hardware acceleration
    dxgi         # DirectX Graphics Infrastructure
    dcomp        # DirectComposition for transparency
    windowscodecs # WIC for image loading (PNG support)
)

# Generate version header
configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in
    ${CMAKE_CURRENT_BINARY_DIR}/version.h
    @ONLY
)

# Include directories
target_include_directories(${PROJECT_NAME} PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/src
    ${CMAKE_CURRENT_BINARY_DIR}
)

# Windows subsystem is set via WIN32 parameter in add_executable

# Copy images to build directory for development (optional)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/neko_down.png ${CMAKE_CURRENT_BINARY_DIR}/neko_down.png COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/neko_up.png ${CMAKE_CURRENT_BINARY_DIR}/neko_up.png COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/neko_icon.png ${CMAKE_CURRENT_BINARY_DIR}/neko_icon.png COPYONLY)
